package com.shop.dao.impl;

import com.shop.dao.ClassifyDao;
import com.shop.dao.base.BaseDao;
import com.shop.entity.Classify;

import java.sql.SQLException;
import java.util.List;

/**
 * @Description TODO
 * @Author hyl
 * @Date 2022/3/10 13:50
 **/
public class ClassifyDaoImpl extends BaseDao<Classify> implements ClassifyDao {
	@Override
	public List<Classify> findClassifyByParentId(Integer parentId) throws SQLException {
		String sql = "SELECT\n" +
				"c.id,\n" +
				"c.classify_name AS classifyName,\n" +
				"c.parent_id AS parentId,\n" +
				"c.type,\n" +
				"c.icon\n" +
				" FROM\n" +
				"t_classify AS c " +
				" where c.parent_id=?";
		parentId = parentId==null ? 0 : parentId;
		return getResultList(sql, new Classify(), new Object[]{parentId});
	}
}
